package tech.aichan.AiQA.model.entity.es;

import cn.hutool.core.bean.BeanUtil;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import tech.aichan.AiQA.model.entity.App;

import java.util.Date;

/**
 * @author mengyu
 * @date 2024/03/04 19:44
 */
@Data
@Document(indexName = "app")
public class AppES {
    @Id
    @Field(type = FieldType.Long)
    private Long id;
    // TODO 智能切分词条 可以切换(ik_max_word/ik_smart)
    @Field(analyzer = "ik_max_word",searchAnalyzer = "ik_max_word",store = true,type = FieldType.Text)
    private String appName;

    @Field(store = true,type = FieldType.Integer)
    private Integer appType;

    @Field(store = true,type = FieldType.Long)
    private Long userId;
    @Field(store = true,type = FieldType.Date)
    private Date createTime;

    public static AppES appToAppES(App app){
        AppES appES = new AppES();
        BeanUtil.copyProperties(app,appES);
        return appES;
    }
}
